package com.yachang.qym.usbhost.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.yachang.qym.usbhost.R;
import com.yachang.qym.usbhost.model.FireCompanyModel;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by qinyuanmao on 16/4/6.
 */
public class FireCompanyAdapter extends BaseAdapter {

    private Context mContext;
    private List<FireCompanyModel> mFireCompanyModels = new ArrayList<>();

    public FireCompanyAdapter(Context context, List<FireCompanyModel> fireCompanyModels){
        mContext = context;
        mFireCompanyModels = fireCompanyModels;
    }

    @Override
    public int getCount() {
        return mFireCompanyModels.size();
    }

    @Override
    public Object getItem(int position) {
        return mFireCompanyModels.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {
            holder=new ViewHolder();
            convertView = LayoutInflater.from(mContext).inflate(R.layout.popup_one_item, null);
            holder.tvName = (TextView) convertView.findViewById(R.id.tv_main_text);
            convertView.setTag(holder);
        }else {
            holder = (ViewHolder)convertView.getTag();
        }
        holder.tvName.setText(mFireCompanyModels.get(position).getName());
        return convertView;
    }

    private class ViewHolder{
        TextView tvName;
    }
}
